package app.ui;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RatingBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import database.local.Deal;
import database.local.PicturesUtil;

public class DetailPopupLayoutData {
	private TextView bName, distance, dName, address;
	private RatingBar rate, money;
	private ImageView image;
	private RelativeLayout layout;
	private Drawable pubPic, restPic;
	
	
	public DetailPopupLayoutData() {
	}

	public void attachLayoutToView(View v, int viewID){
		layout = (RelativeLayout) v.findViewById(viewID);
	}
	
	/**
	 * 
	 * @param b (true/false --> visible/gone)
	 */
	public void setVisibilty (Boolean b){
		if (b)
			layout.setVisibility(LinearLayout.VISIBLE);
		else
			layout.setVisibility(LinearLayout.GONE);
	}
	
	public ViewGroup getLayout(){
		return layout;
	}
	
	public void attachRateToView(View v, int viewID){
		rate = (RatingBar) v.findViewById(viewID);
	}
	
	public void setRate(int rate) {
		this.rate.setRating(rate);
	}
	
	public void attachBNameToView(View v, int viewID){
		bName = (TextView) v.findViewById(viewID);
	}
	
	public void setBNameText (String str){
		bName.setText(str);
	}
	
	public void attachDistanceToView(View v, int viewID){
		distance = (TextView) v.findViewById(viewID);
	}
	
	public void setDistanceText (String str){
		distance.setText(str);
	}
	
	public void attachAddressToView(View v, int viewID){
		address = (TextView) v.findViewById(viewID);
	}
	
	public void setAddressText (String str){
		address.setText(str);
	}
	
	
	public void attachDNameToView(View v, int viewID){
		dName = (TextView) v.findViewById(viewID);
	}
	
	public void setDNameText (String str){
		dName.setText(str);
	}

	public void attachMoneyToView(View v, int viewID) {
		money = (RatingBar) v.findViewById(viewID);
		
	}
	
	public void setMoney (int money){
		this.money.setRating(money);
	}
	
	public void attachImageToView (View v, int viewID){
		image = (ImageView) v.findViewById(viewID);
	}
	
	public void setImage (Deal d, Context context){
		image.setImageDrawable(PicturesUtil.getDealPicSmall(d, context));
	}
	
	
}
